<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"
        integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog=="
        crossorigin="anonymous" />
        <link rel="stylesheet" href="style.css" />
    <title>Document</title>
</head>
<body>
    <div class="search">
        <input type="text" class="input" placeholder="请输入内容">
        <button class="btn"> <i class="fas fa-search"></i> </button>
    </div>

    <script>
        const search = document.querySelector('.search')
        const input = document.querySelector('.input')
        const btn = document.querySelector('.btn')

        btn.addEventListener('click',function(){
            search.classList.toggle('active')
            input.focus()
        })
    </script>
</body>
</html>